using UnityEngine;
using System.Collections.Generic;

public class BgScript : MonoBehaviour {

    private float shiftYinitial;// = MainScript.bgShiftYInitial;
    void Start()
    {
		//how much further the piece will move every frame
        shiftYinitial = MainScript.bgShiftYInitial;
    }

    void Update(){
        transform.Translate(Vector3.up*(Time.deltaTime * shiftYinitial));
		//if piece is outside the screen, put it down
		//1.5f make it later than just on the first frame outside the screen avoiding black lines on the top
        if (transform.position.y > (MainScript.cameraSize*2.0f)*1.5f)
        {
            transform.position -= Vector3.up * collider.bounds.size.y*MainScript.bgCount;
			//put this piece on the top of the stack of background instances
			GameScript.updateBgList();
        }
    }
}
